<% content_for :sitemap do %>
  <span class="current"><%= t("admin.menu.replies") %></span>
<% end %>

<div class="toolbar">
  <form class="form-inline" action="<%= admin_replies_path %>">
    <div class="form-group mr-sm-2">
      <input type="text" name="q" class="form-control" value="<%= params[:q] %>" placeholder="标题" />
    </div>
    <div class="form-group mr-sm-2">
      <input type="text" name="login" class="form-control" value="<%= params[:login] %>" placeholder="用户名" />
    </div>
    <button class="btn btn-default">搜索</button>
  </form>
</div>


<table class="table table-bordered table-striped table-condensed">
  <tr class="head">
    <td class="first">#</td>
    <td style="width:500px">回帖内容</td>
    <td>话题</td>
    <td>回复人</td>
    <td>时间</td>
    <td>仅楼主可见</td>
    <td>ip info</td>
    <td></td>
  </tr>

<% @replies.each do |reply| %>
  <tr id="reply-<%= reply.id %>" class="<%= "deleted" if !reply.deleted_at.blank? %>">
    <td class="first"><%= reply.id %></td>
    <td><%= truncate(reply.body, length: 50) %></td>
    <% if reply.topic %>
      <td>
          <%= link_to(reply.topic_id, topic_path(reply.topic_id), title: reply.topic.title) %>
      </td>
      <% else %>
      <td><%= reply.topic_id %></td>
      <% end %>
    <td><%= link_to(reply.user.login, edit_admin_user_path(reply.user_id), target: "_blank") if reply.user %></td>
    <td><%= l reply.created_at, format: :short %></td>
    <td><%= reply.exposed_to_author_only %></td>
    <td><%= "#{reply.ip}" %><%= reply.remote_port.present? ? " :#{reply.remote_port}" : "" %>
    <%== reply.ip_location.present? ? "<br> #{reply.ip_location}" : "" %>
    </td>
    <td><%= link_to "", edit_admin_reply_path(reply), class: "fa fa-edit" %>
    <%= link_to "", admin_reply_path(reply), "data-confirm" => "Are you sure?", method: :delete, remote: true, class: "fa fa-trash" %></td>
  </tr>
<% end %>
</table>
<%= paginate @replies %>

